package com.yipei.business.controller;

import com.yipei.business.domain.MlServiceUrl;
import com.yipei.business.service.IMlServiceUrlService;
import com.yipei.common.annotation.Log;
import com.yipei.common.core.controller.BaseController;
import com.yipei.common.core.domain.AjaxResult;
import com.yipei.common.core.page.TableDataInfo;
import com.yipei.common.enums.BusinessType;
import com.yipei.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 客服管理Controller
 *
 * @author yipei
 * @date 2024-12-21
 */
@RestController
@RequestMapping("/business/customer")
@Api(tags = "客服管理", description = "客服管理")
public class MlServiceUrlController extends BaseController {
    @Autowired
    private IMlServiceUrlService mlServiceUrlService;

    /**
     * 查询客服管理列表
     */
    //@PreAuthorize("@ss.hasPermi('business:customer:list')")
    @ApiOperation("客服管理获取数据")
    @GetMapping("/list")
    public TableDataInfo list(MlServiceUrl mlServiceUrl) {
        startPage();
        List<MlServiceUrl> list = mlServiceUrlService.selectMlServiceUrlList(mlServiceUrl);
        return getDataTable(list);
    }

    /**
     * 导出客服管理列表
     */
    //@PreAuthorize("@ss.hasPermi('business:customer:export')")
    @ApiOperation("客服管理导出数据")
    @Log(title = "客服管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MlServiceUrl mlServiceUrl) {
        List<MlServiceUrl> list = mlServiceUrlService.selectMlServiceUrlList(mlServiceUrl);
        ExcelUtil<MlServiceUrl> util = new ExcelUtil<MlServiceUrl>(MlServiceUrl.class);
        util.exportExcel(response, list, "客服管理数据");
    }

    /**
     * 获取客服管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('business:customer:query')")
    @ApiOperation("客服管理通过ID获取数据")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mlServiceUrlService.selectMlServiceUrlById(id));
    }

    /**
     * 新增客服管理
     */
    //@PreAuthorize("@ss.hasPermi('business:customer:add')")
    @ApiOperation("客服管理新增数据")
    @Log(title = "客服管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MlServiceUrl mlServiceUrl) {
        return toAjax(mlServiceUrlService.insertMlServiceUrl(mlServiceUrl));
    }

    /**
     * 修改客服管理
     */
    //@PreAuthorize("@ss.hasPermi('business:customer:edit')")
    @ApiOperation("客服管理修改数据")
    @Log(title = "客服管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MlServiceUrl mlServiceUrl) {
        return toAjax(mlServiceUrlService.updateMlServiceUrl(mlServiceUrl));
    }

    /**
     * 删除客服管理
     */
    //@PreAuthorize("@ss.hasPermi('business:customer:remove')")
    @ApiOperation("客服管理删除数据")
    @Log(title = "客服管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mlServiceUrlService.deleteMlServiceUrlByIds(ids));
    }
}
